<template>
    <div>
        <div class="section">
            <div class="swiper-container"
                 ref="slider">
                <div class="swiper-wrapper">
                    <div class="swiper-slide" v-for="slide in slides">
                        <img :src="slide.img_url">
                    </div>
                </div>
                <div class="swiper-pagination"
                     ref="pagination"></div>
            </div>
            <div class="announcement">
                <label>快讯</label>
                <span>今日上架的图书全部8折</span>
            </div>
        </div>
        <div class="section">
            <div class="book-list">
                <div class="header">
                    <div class="heading">最新更新</div>
                    <div class="more">更多...</div>
                </div>
                <div class="book-items">
                    <div class="book"
                         v-for="book in books">
                        <div class="cover">
                            <img :src="book.img_url"/>
                        </div>
                        <div class="title">{{ book.title }}</div>
                        <div class="authors">{{ book.authors | join }}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default{
        name: 'app',
        data(){
            return {
                slides: [{img_url: require("./fixtures/sliders/t1.svg")},
                    {img_url: require("./fixtures/sliders/t2.svg")}]
            }
        }
    }
</script>
<style>
    .announcement {
        font-size: 12px;
        padding: 5px;
        background: #fff;
    }

    .announcement > label {
        padding: 3px 10px;
        margin: 3px 10px;
        background: #FACCB7;
        border-radius: 3px;
        color: #FF5102;

    }

    .announcement > span {
        padding: 3px 10px;
        color: #333;
        display: inline-block;
    }

    .swiper-container {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .swiper-wrapper {
        height: 200px;
    }

    .swiper-slide img {
        max-width: 100%;
    }

    .swiper-slide {
        text-align: center;
        background: #fff;
        /* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
    }
</style>

<script type="text/ecmascript-6">
    import Swiper from "swiper"
    import '../node_modules/swiper/dist/css/swiper.css'
    import "./list.less"

    export default{
        props: ['Home'],
        data(){
            return {
                slides: [{img_url: require('./fixtures/sliders/t1.svg')}, {img_url: require('./fixtures/sliders/t2.svg')}],
                books: [{
                    img_url: require("./fixtures/covers/1.svg"),
                    title: '揭开数据真像：从小白到数据分析达人',
                    authors: 'Edward Zaccaro,Daniel Zaccaro'
                },
                    {img_url: require("./fixtures/covers/2.svg"), title: 'Android 高级进阶', authors: '顾浩鑫'},
                    {img_url: require("./fixtures/covers/3.svg"), title: '淘宝天猫电商运营与数据化选品完全手册', authors: '老夏'},
                    {img_url: require("./fixtures/covers/4.svg"), title: '大数据架构详解：从数据获取到深度学习', authors: '朱洁,罗华霖'},
                    {img_url: require("./fixtures/covers/5.svg"), title: 'Meteor 全栈开发', authors: '杜亦舒'},
                    {
                        img_url: require("./fixtures/covers/6.svg"),
                        title: 'Kubernetes权威指南：从Docker到Kubernetes时间全接触（第2版）',
                        authors: '龚正，吴治辉，王伟，崔秀龙，闫建勇'
                    }]
            }

        },
        mounted() {
            debugger
            new Swiper(this.$refs.slider, {
                pagination: this.$refs.pagination,
                paginationClickable: true,
                spaceBetween: 30,
                centeredSlides: true,
                autoplay: 2500,
                autoplayDisableOnInteraction: false
            })
        }
    }
</script>